/*
  S.M.A.C.K - An operating system kernel
  Copyright (C) 2010,2011 Mattias Holm and Kristian Rietveld
  For licensing and a full list of authors of the kernel, see the files
  COPYING and AUTHORS.
*/

#include <stdint.h>

/* A tiny graphics library.
 * To do:
 *   - Double buffering with swap buffers signal (needs kernel support, ioctl)
 *   - Kernel support for acquiring resolution of screen (iotcl).
 *   - Kernel call to clear the screen (ioctl).
 *   - Optimized line drawing (only use a single system call for this).
 *   - Much more.
 */

/* Color palette */
#define RGB565(r, g, b) ((r >> 3) << 11)| ((g >> 2) << 5)| ((b >> 3) << 0)

#define BLACK 0x0000
#define WHITE 0xffff

/* GNOME 32-color palette
 * http://library.gnome.org/devel/hig-book/stable/design-color.html.en
 */
#define N_COLORS 32

static uint16_t gfx_color_palette[N_COLORS] =
{
  RGB565(234, 232, 227),
  RGB565(128, 125, 116),
  RGB565(197, 210, 200),
  RGB565(93, 117, 85),
  RGB565(224, 182, 175),
  RGB565(136, 70, 49),
  RGB565(173, 167, 200),
  RGB565(98, 91, 129),
  RGB565(157, 184, 210),
  RGB565(75, 105, 131),
  RGB565(239, 224, 205),
  RGB565(179, 145, 105),
  RGB565(223, 66, 30),
  RGB565(238, 214, 128),
  RGB565(70, 160, 70),
  RGB565(255, 255, 255),
  RGB565(186, 181, 171),
  RGB565(86, 82, 72),
  RGB565(131, 166, 127),
  RGB565(68, 86, 50),
  RGB565(193, 102, 90),
  RGB565(102, 56, 34),
  RGB565(136, 127, 163),
  RGB565(73, 64, 102),
  RGB565(117, 144, 174),
  RGB565(49, 78, 108),
  RGB565(224, 195, 158),
  RGB565(130, 102, 71),
  RGB565(153, 0, 0),
  RGB565(209, 148, 12),
  RGB565(38, 199, 38),
  RGB565(0, 0, 0)
};


int gfx_open(void);
void gfx_close(void);

int gfx_get_width(void);
int gfx_get_height(void);

void gfx_clear(uint16_t color);
void gfx_set_pixel(int x, int y, uint16_t color);
void gfx_fill_rect(int x, int y, int w, int h, uint16_t color);
void gfx_stroke_rect(int x, int y, int w, int h, uint16_t color);
void gfx_fill_dot(int x, int y, int t, uint16_t color);
